<?php
/**
 * 活动商品模板
 *
 * by abc.com 多用户商城
 *
 *
 */
//by abc.com
//use Shopnc\Tpl;

defined('InShopNC') or exit('Access Invalid!');
class goods_tp_listControl extends mobileHomeControl{

	public function __construct() {
        parent::__construct();
    }
    
    public function goods_template_listOp()
    {
        //首先先把所有找出来，
        //然后进行分类，广告大图，小图
        //代金券
        //商品，大图小图
        $condition['is_active']=1;
        $condition['gt_class_id']=$_REQUEST['gt_class_id'];
        $gt_class_model=Model('gt_class');
        $gt_class_info=$gt_class_model->gt_class_list($condition);
        if(!empty($gt_class_info)){
            $condition_gt['gt_class_id']=$gt_class_info['gt_class_id'];
        }else{
            output_data(array('status'=>'error','msg'=>'该活动模板没开启或不存在'));
        }
        $goods_templates_model=Model('goods_templates');
        $goods_tp_list=$goods_templates_model->goods_tp_list($condition_gt);
  
        if (!empty($goods_tp_list)){
            foreach ($goods_tp_list as $key =>$val){
                $gs_tp_image=UPLOAD_SITE_URL.'/'.GT_TEMPLATES.'/'.$val['gs_tp_image'];
                $goods_tp_list[$key]['gs_tp_image']=$gs_tp_image;
                if ($val['is_goods']){
                    $goods_model=Model('goods');
                    $condition_go['goods_id']=$val['goods_id'];
                    $goods_info=$goods_model->getGoodsInfo($condition_go);
                    $goods_tp_list[$key]['goods_name']=$goods_info['goods_name'];
                    $goods_tp_list[$key]['goods_price']=$goods_info['goods_price'];
                    $image=cthumb($goods_info['goods_image'],240,$goods_info['store_id']);
                    $goods_tp_list[$key]['goods_image']=$image;
                }
                if($val['is_voucher']){
                    $voucher_model=Model('voucher');
                    $condition_vr['voucher_t_id']=$val['voucher_t_id'];
                    $voucher_info=$voucher_model->getVoucher_template($condition_vr);
                    $goods_tp_list[$key]['voucher']=$voucher_info['voucher_t_title'].'--满'.$voucher_info['voucher_t_limit'].'减'.$voucher_info['voucher_t_price'];
            
                }
                 
            }
            output_data(array('status'=>'success','goods_tp_list'=>$goods_tp_list));
        }else{
            output_data(array('status'=>'error','msg'=>'无活动'));
        }
   
    }
}